/**
 * Desenvolvido pela Fábrica de Software do CESUPA.
 * Todos os direitos reservados.
 */
package br.cesupa.fabsoft.nomedoprojeto.system.application.facades;

import br.cesupa.fabsoft.nomedoprojeto.system.application.beans.ApplicationStatusBean;
import br.cesupa.fabsoft.nomedoprojeto.system.infra.view.Message;
import br.cesupa.fabsoft.nomedoprojeto.system.infra.view.MessageFactory;
import br.cesupa.fabsoft.nomedoprojeto.system.infra.view.MessageType;
import java.util.Locale;
import javax.faces.context.FacesContext;

/**
 * Summarize common operations related to the view.
 *
 * @author Breno Leite
 */
public class ViewFacade {

    /**
     * Defines the {@link Locale} to be used in the view rendering.
     *
     * @param locale the {@link Locale} to be used
     */
    public void setViewLocale(final Locale locale) {
        FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
    }

    public ApplicationStatusBean manageApplicationStatus() {
        return ApplicationStatusBean.getCurrentInstance();
    }

    /**
     * @see MessageFactory#createMessage(java.lang.String, br.cesupa.fabsoft.nomedoprojeto.system.infra.MessageType)
     */
    public Message createMessage(final String messageKey, final MessageType messageType) {
        return new MessageFactory().createMessage(messageKey, messageType);
    }

    /**
     * @see FacesMessageFacade
     */
    public FacesMessageFacade manageFacesMessages() {
        return new FacesMessageFacade();
    }

    /**
     * @see TranslationFacade
     */
    public TranslationFacade manageTranslations() {
        return new TranslationFacade();
    }
}
